﻿using System.Collections.Generic;

namespace Red.Launcher.ViewModels.Workspaces.Database
{
    public class ClientParameter : Record
    {
        #region Private Data

        private string _value;

        #endregion Private Data

        #region Public Properties

        public static Metadata METADATA { get; private set; }

        public string Value
        {
            get { return _value; }
            set
            {
                if ( _value != value )
                {
                    _value = value;
                    OnPropertyChanged();
                }
            }
        }

        #endregion Public Properties

        #region Inherited Properties

        public override Metadata Metadata { get { return METADATA; } }
        public override string Icon { get { return "appbar_axis_xy_parentheses"; } }
        public override IEnumerable<object> Values { get { return new List<object>() { Name, Value }; } }

        #endregion Inherited Properties

        #region C-Tor

        static ClientParameter()
        {
            METADATA = new Metadata()
            {
                Table = "ClientParameters",
                CanCopy = true,
                Keys = new List<string>() { "parameter", "value" },
                CreateDefault = () => { return new ClientParameter(); },
                CreateFromDatabaseRow = ( Dictionary<string, object> data ) =>
                {
                    return new ClientParameter()
                    {
                        Id = (int)data[ "id" ],
                        Name = (string)data[ "parameter" ],
                        Value = (string)data[ "value" ]
                    };
                }
            };
        }

        public ClientParameter()
        {
        }

        public ClientParameter( ClientParameter other )
        {
            Name = other.Name;
            Value = other.Value;
        }

        #endregion C-Tor
    }
}
